import * as types from "../types/placeRecycleOrderTypes";

const initialState = {
  loading: false,
  error: undefined,
  contractor: "",
  mobile: "",
  idCard: "",
  alipay_no: "",
  alipay_name: "",
  weichat_name: "",
  weichat_no: "",
  collectionType: 1,
};

export default function editAddressReducer(state = initialState, action) {
  switch (action.type) {
    case types.PLACERECYCLEORDER_LOADING:
      return {
        ...state,
        loading: true,
      };
    case types.PLACERECYCLEORDER_DOWN:
      return {
        ...state,
        loading: false,
      };
    case types.PLACERECYCLEORDER_ERROR:
      return {
        ...state,
        loading: false,
        error: action.error,
      };
    case types.CONTRACTOR_CHANGE:
      return {
        ...state,
        contractor: action.contractor,
      };
    case types.MOBILE_CHANGE:
      return {
        ...state,
        mobile: action.mobile,
      };
    case types.IDCARD_CHANGE:
      return {
        ...state,
        idCard: action.idCard,
      };
    case types.ALIPAY_NAME_CHANGE:
      return {
        ...state,
        alipay_name: action.alipay_name,
      };
    case types.ALIPAY_NUMBER_CHANGE:
      return {
        ...state,
        alipay_no: action.alipay_no,
      };
    case types.WEICHATPAY_NAME_CHNAGE:
      return {
        ...state,
        weichat_name: action.weichat_name,
      };
    case types.WEICHATPAY_NUMBER_CHNAGE:
      return {
        ...state,
        weichat_no: action.weichat_no,
      };
    case types.COLLECTIONTYPE_CHANGE:
      return {
        ...state,
        collectionType: action.collectionType,
      };
    case types.PLACERECYCLEORDER_UNMOUNT:
      return {
        ...initialState,
      };
    default:
      return state;
  }
}
